package com.geo.auth.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.Builder;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

/**
 * 用户角色关联实体类
 * 
 * @author GEO Team
 * @version 1.0
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@TableName("sys_user_role")
public class UserRole {
    
    // 手动添加builder方法以解决编译问题
    public static UserRoleBuilder builder() {
        return new UserRoleBuilder();
    }
    
    public static class UserRoleBuilder {
        private String id;
        private String userId;
        private String roleId;
        private LocalDateTime createdAt;
        private String createdBy;
        private Integer deleted;
        
        public UserRoleBuilder id(String id) {
            this.id = id;
            return this;
        }
        
        public UserRoleBuilder userId(String userId) {
            this.userId = userId;
            return this;
        }
        
        public UserRoleBuilder roleId(String roleId) {
            this.roleId = roleId;
            return this;
        }
        
        public UserRoleBuilder createdAt(LocalDateTime createdAt) {
            this.createdAt = createdAt;
            return this;
        }
        
        public UserRoleBuilder createdBy(String createdBy) {
            this.createdBy = createdBy;
            return this;
        }
        
        public UserRoleBuilder deleted(Integer deleted) {
            this.deleted = deleted;
            return this;
        }
        
        public UserRole build() {
            UserRole userRole = new UserRole();
            userRole.id = this.id;
            userRole.userId = this.userId;
            userRole.roleId = this.roleId;
            userRole.createdAt = this.createdAt;
            userRole.createdBy = this.createdBy;
            userRole.deleted = this.deleted;
            return userRole;
        }
    }
    
    /**
     * 关联ID
     */
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    private String id;
    
    /**
     * 用户ID
     */
    @TableField("user_id")
    private String userId;
    
    /**
     * 角色ID
     */
    @TableField("role_id")
    private String roleId;
    
    /**
     * 创建时间
     */
    @TableField(value = "created_at", fill = FieldFill.INSERT)
    private LocalDateTime createdAt;
    
    /**
     * 创建者ID
     */
    @TableField("created_by")
    private String createdBy;
    
    /**
     * 逻辑删除标志
     */
    @TableLogic
    @TableField("deleted")
    private Integer deleted;
}

/**
 * 角色权限关联实体类
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@TableName("sys_role_permission")
class RolePermission {
    
    /**
     * 关联ID
     */
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    private String id;
    
    /**
     * 角色ID
     */
    @TableField("role_id")
    private String roleId;
    
    /**
     * 权限ID
     */
    @TableField("permission_id")
    private String permissionId;
    
    /**
     * 创建时间
     */
    @TableField(value = "created_at", fill = FieldFill.INSERT)
    private LocalDateTime createdAt;
    
    /**
     * 创建者ID
     */
    @TableField("created_by")
    private String createdBy;
    
    /**
     * 逻辑删除标志
     */
    @TableLogic
    @TableField("deleted")
    private Integer deleted;
}